import 'package:flutter/material.dart';

/// 应用核心常量配置
class AppConstants {
  // 私有构造函数，防止实例化
  AppConstants._();
  
  // =================== 应用信息 ===================
  static const String appName = '拼图大师';
  static const String appVersion = '1.0.0';
  
  // =================== 游戏配置 ===================
  /// 默认拼图网格大小
  static const int defaultGridSize = 3;
  
  /// 支持的难度级别
  static const List<int> supportedGridSizes = [3, 4, 5, 6];
  
  /// 拼图面板尺寸
  static const double puzzleBoardSize = 300.0;


  
  /// 拼图块之间的间隔
  static const double puzzlePieceSpacing = 2.0;
  
  /// 自动吸附阈值（像素）
  static const double snapThreshold = 25.0;
  
  /// 散落区域配置
  static const double scatterAreaTop = 400.0;
  static const double scatterAreaHeight = 200.0;
  
  // =================== UI配置 ===================
  /// 默认动画时长
  static const Duration defaultAnimationDuration = Duration(milliseconds: 300);
  
  /// 拖拽动画时长
  static const Duration dragAnimationDuration = Duration(milliseconds: 150);
  
  /// 完成动画时长
  static const Duration completionAnimationDuration = Duration(milliseconds: 500);
  
  /// 默认边距
  static const EdgeInsets defaultPadding = EdgeInsets.all(16.0);
  static const EdgeInsets smallPadding = EdgeInsets.all(8.0);
  static const EdgeInsets largePadding = EdgeInsets.all(24.0);
  
  /// 默认圆角
  static const BorderRadius defaultBorderRadius = BorderRadius.all(Radius.circular(8.0));
  static const BorderRadius largeBorderRadius = BorderRadius.all(Radius.circular(16.0));
  
  // =================== 颜色配置 ===================
  /// 主题颜色
  static const Color primaryColor = Color(0xFF2196F3);
  static const Color primaryColorLight = Color(0xFF64B5F6);
  static const Color primaryColorDark = Color(0xFF1976D2);
  
  /// 功能颜色
  static const Color successColor = Color(0xFF4CAF50);
  static const Color warningColor = Color(0xFFFF9800);
  static const Color errorColor = Color(0xFFf44336);
  
  /// 中性颜色
  static const Color backgroundColor = Color(0xFFF5F5F5);
  static const Color surfaceColor = Color(0xFFFFFFFF);
  static const Color onSurfaceColor = Color(0xFF212121);
  
  // =================== 图片资源 ===================
  /// 内置图片资源路径
  static const List<String> defaultImages = [
    'assets/images/nature/sunset.jpg',
    'assets/images/nature/forest.jpg',
    'assets/images/nature/ocean.jpg',
    'assets/images/animals/cat.jpg',
    'assets/images/animals/dog.jpg',
    'assets/images/animals/bird.jpg',
    'assets/images/architecture/castle.jpg',
    'assets/images/architecture/bridge.jpg',
    'assets/images/architecture/temple.jpg',
  ];
  
  /// 图片主题分类
  static const Map<String, List<String>> imageCategories = {
    '自然风光': [
      'assets/images/nature/sunset.jpg',
      'assets/images/nature/forest.jpg',
      'assets/images/nature/ocean.jpg',
    ],
    '动物世界': [
      'assets/images/animals/cat.jpg',
      'assets/images/animals/dog.jpg',
      'assets/images/animals/bird.jpg',
    ],
    '建筑艺术': [
      'assets/images/architecture/castle.jpg',
      'assets/images/architecture/bridge.jpg',
      'assets/images/architecture/temple.jpg',
    ],
  };
  
  // =================== 存储配置 ===================
  /// SharedPreferences 键名
  static const String keyBestTime = 'best_time';
  static const String keyTotalGames = 'total_games';
  static const String keyCompletedGames = 'completed_games';
  static const String keyCurrentDifficulty = 'current_difficulty';
  static const String keySelectedTheme = 'selected_theme';
  static const String keySoundEnabled = 'sound_enabled';
}

/// 游戏状态枚举
enum GameStatus {
  initial('初始状态'),
  loading('加载中'),
  playing('游戏中'),
  paused('已暂停'),
  completed('已完成'),
  failed('游戏失败');
  
  const GameStatus(this.displayName);
  final String displayName;
}

/// 难度级别枚举
enum DifficultyLevel {
  easy(3, '简单', Color(0xFF4CAF50)),
  medium(4, '普通', Color(0xFFFF9800)),
  hard(5, '困难', Color(0xFFf44336)),
  expert(6, '专家', Color(0xFF9C27B0));
  
  const DifficultyLevel(this.gridSize, this.displayName, this.color);
  
  final int gridSize;
  final String displayName;
  final Color color;
  
  /// 计算拼图块总数
  int get totalPieces => gridSize * gridSize;
  
  /// 计算单个拼图块尺寸
  double get pieceSize => AppConstants.puzzleBoardSize / gridSize;
}
